home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / taropyon / silib / silib.lzh / PRG / SDKFS / FSELDSP.C < prev    next >
C/C++ Source or Header  |  1993-12-03  |  10KB  |  373 lines

  1. /*************************************************************************
  2. *    âtâ@âCâïâZâîâNâ^
  3. *************************************************************************/
  4.  
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7. #include    <msdos.cf>
  8.  
  9. #include    <kbcode.h>
  10. #include    <sipd.h>
  11. #include    <sicoltbl.h>
  12. #include    <sifs.h>
  13. #include    <siptn.h>
  14.  
  15. #include    "sdkfs.h"
  16. #include    "sdkfscf.h"
  17.  
  18. #if    0
  19.     +--+--------------------+--+
  20.     |  |                    |  |
  21.     |--+--------------------+--|
  22.     |A B C D E F G H I J K L M |
  23.     |N O P Q R S T U V W X Y Z |
  24.     |+----------------------+  |
  25.     ||                      |üú|
  26.     ||                      |  |
  27.     ||                      |  |
  28.     ||                      |  |
  29.     ||                      |  |
  30.     ||                      |  |
  31.     ||                      |üÑ|
  32.     |+----------------------+  |
  33.     |                          |
  34.     +--------------------------+
  35. #endif
  36.  
  37. extern int            BlkDlgMoveEvFunc( int evNo, EVDAT_T *evdat );
  38.  
  39. static char    *GetSizeStr( char *buf, size_t siz )
  40. {
  41.     if ( siz < 1024 )
  42.         sprintf( buf, "%4uB", siz );
  43.     else if ( siz < 1024*1024 )
  44.     {
  45.         if ( siz < 100*1024 )
  46.             sprintf( buf, "%2u.%uK", siz / 1024, (100*(siz&1023)/1024)/10 );
  47.         else
  48.             sprintf( buf, "%4uK", siz / 1024 );
  49.     } else
  50.     {
  51.         if ( siz < 100*1024*1024 )
  52.             sprintf( buf, "%2u.%uM", siz / (1024*1024), (100*((siz/1024)&1023)/1024)/10 );
  53.         else
  54.             sprintf( buf, "%4uM", siz / (1024*1024) );
  55.     }
  56.  
  57.     return (buf);
  58. }
  59.  
  60. /*************************************************************************
  61. *    âtâ@âCâïû╝êΩùùé╠ò\Ī
  62. *************************************************************************/
  63.  
  64. void        FileSel_dspFndat( FILESEL_T *fs, int pos )
  65. {
  66.     int            i, y;
  67.     CONST int    x1 = fs->frFl.x1, x2 = fs->frFl.x2;
  68.     LAYER_T        *ly = SiScn->layerCrt;
  69.  
  70.     {
  71.         SB_T    *sb = fs->sb;
  72.  
  73.         sb->total = fs->numMat;
  74.         sb->min   = 0;
  75.         sb->max   = fs->numMat - 1;
  76.         sb->top   = fs->posDspTop;
  77.         sb->wid   = FSDSP_FNUM;
  78.     }
  79.  
  80.     MOS_DEC();
  81.     for ( i = 0; i < FSDSP_FNUM; ++i )
  82.     {
  83.         int        p;
  84.  
  85.         p = fs->posDspTop + i;
  86.         y = fs->frFl.y1 + 2 + i * 12;
  87.  
  88.         if ( pos < 0 || pos == p )
  89.         {
  90.             if ( fs->posDspTop + i < fs->numMat )
  91.             {
  92.                 FNDAT_T        *fndat;
  93.                 char        tmp[32], fn[16], sub[8];
  94.                 COLOR_T        col, bac;
  95.  
  96.                 fndat = fs->fnMat[fs->posDspTop + i];
  97.                 FS_getFn(fn ,fndat->buf.name);
  98.                 FS_getSn(sub,fndat->buf.name);
  99.                 bac = ly->col.black;
  100.                 if ( fndat->buf.attrib & FSATT_DIR )
  101.                 {    /* âfâBâîâNâgâè */
  102.                     col = C_HYELLOW;
  103.                     sprintf( tmp,"%-8s.%-3s <DIR>", fn, sub );
  104.                 } else
  105.                 {
  106.                     char    buf[8];
  107.  
  108.                     switch ( fndat->buf.attrib & (FSATT_SYS|FSATT_RO) )
  109.                     {
  110.                         case FSATT_SYS:
  111.                             col = ly->colTbl[8+1];
  112.                             break;
  113.                         case FSATT_RO:
  114.                             col = ly->colTbl[8+2];
  115.                             break;
  116.                         case FSATT_SYS|FSATT_RO:
  117.                             col = ly->colTbl[8+3];
  118.                             break;
  119.                         default:
  120.                             col = ly->col.gray;
  121.                             break;
  122.                     }
  123.                     sprintf( tmp,"%-8s.%-3s %s",
  124.                         fn, sub, GetSizeStr(buf,fndat->buf.size) );
  125.                 }
  126.                 if ( fndat->mark )
  127.                 {
  128.                     COLOR_T    memo;
  129.                     memo = col, col = bac, bac = memo;
  130.                 }
  131.             /*    SCN_BOXF(x1,y,x2,y+11,PSET,bac); */
  132.                 SCN_PUTS(SiFts->ftsSs2,tmp,x1+2,y,OPAQUE,col,bac);
  133.  
  134.                 if ( pos < 0 )
  135.                 {
  136.                     EV_SETFR(fs->evFn, i, p, fs, fsEvFunc_file,
  137.                         NULL, EVSW_LEFT,x1,y,x2,y+11);
  138.                 }
  139.             } else
  140.             {
  141.                 SCN_BOXF(x1,y,x2,y+11,PSET,ly->col.black);
  142.                 if ( pos < 0 )
  143.                     EV_datUnset( fs->evFn, i);
  144.             }
  145.  
  146.             if ( pos == p )
  147.                 break;
  148.         }
  149.     }
  150.     MOS_INC();
  151. }
  152.  
  153. /*************************************************************************
  154. *    ôⁿù═âtâ@âCâïû╝é╠ò\Ī
  155. *************************************************************************/
  156.  
  157. void        FileSel_dspFnbuf( FILESEL_T *fs )
  158. {
  159.     LAYER_T        *ly = SiScn->layerCrt;
  160.     int            xx1 = fs->fr.x1 + 2, yy1 = fs->fr.y2+1 - 2 - 12;
  161.     int            xx2 = fs->frFl.x2-1, yy2 = yy1 + 11;
  162.  
  163.     MOS_DEC();
  164.     SCN_BOXF(xx1,yy1,xx2,yy2,PSET,ly->col.black);
  165.     if ( fs->buf[0] )
  166.     {
  167.         char    tmp[80];
  168.  
  169.         FS_getFnam( tmp, fs->buf );
  170.         SCN_PUTS(SiFts->ftsSs2,tmp,xx1+2,yy1,OPAQUE,ly->col.gray,ly->col.black);
  171.     }
  172.     MOS_INC();
  173. }
  174.  
  175. /*************************************************************************
  176. *    âGâëü[ò\Ī
  177. *************************************************************************/
  178.  
  179. void    FileSel_dspErr(FILESEL_T *fs)
  180. {
  181.     CONST int    x1 = fs->frFl.x1+1, x2 = fs->frFl.x2-1;
  182.     CONST int    y1 = fs->frFl.y1+1, y2 = fs->frFl.y2-1;
  183.     LAYER_T        *ly = SiScn->layerCrt;
  184.     char        *msg;
  185.  
  186.     MOS_DEC();
  187.     SCN_BOXF(x1,y1,x2,y2,PSET,ly->col.black);
  188.     switch ( fs->err )
  189.     {
  190.         case FSERR_DRIVE:    msg = "Drive not ready";    break;
  191.         case FSERR_FILE:    msg = "File not found";        break;
  192.         case FSERR_MEMORY:    msg = "Memory error";        break;
  193.         default:            msg = "Sdkfs error";        break;
  194.     }
  195.     SCN_PUTS(SiFts->ftsSs2,msg,x1+2,(y1+y2-12)/2,OPAQUE,ly->colTbl[8+2],ly->col.black);
  196.     MOS_INC();
  197. }
  198.  
  199. /*************************************************************************
  200. *    â_âCâAâìâOò\Īè╓Éö
  201. *************************************************************************/
  202.  
  203. void    fsFunc_dlgdsp( BLKDLG_T *dlg )
  204. {
  205.     FILESEL_T        *fs = dlg->ptr;
  206.     int                x1 = dlg->rect.x0 + 2;
  207.     int                y1 = dlg->rect.y0 + 2;
  208.     int                x2 = dlg->rect.x0 + dlg->rect.xs - 1 -2;
  209.     int                y2 = dlg->rect.y0 + dlg->rect.ys - 1 -2;
  210.     EV_T            *ev = fs->ev;
  211.     int                evPos = 0;
  212.     void            *win = NULL;
  213.     LAYER_T            *ly = SiScn->layerCrt;
  214.     CONST COLOR_T    sha = ly->col.dark, hil = ly->col.white;
  215.  
  216.     fs->fr.x1 = x1;
  217.     fs->fr.y1 = y1;
  218.     fs->fr.x2 = x2;
  219.     fs->fr.y2 = y2;
  220.  
  221.     /* âNâìü[âYâ{â^âô    ------------------------------------------------*/
  222.     {
  223.         CONST int    xx1 = x1   , yy1 = y1;
  224.         CONST int    xx2 = x1+15, yy2 = y1+15;
  225.  
  226.         SCN_PUTIMGPTN( &Ptn16x16_close, xx1, yy1, OPAQUE, ly->col.black,ly->col.gray);
  227.         SCN_BOXCON(xx1,yy1,xx2,yy2,1,PSET,hil, sha);
  228.         EV_SETBTN1(ev,evPos++, FSEV_EXIT, fs, fsEvFunc_exit,
  229.             win, EVSW_LEFT,xx1,yy1,xx2,yy2,1,hil,sha);
  230.     }
  231.  
  232.     /* â^âCâgâï    --------------------------------------------------------*/
  233.     {
  234.         CONST int    xx1 = x1 + 16, yy1 = y1;
  235.         CONST int    xx2 = x2 - 16, yy2 = y1 + 15;
  236.  
  237.         SCN_BOXFCON(xx1,yy1,xx2,yy2,1,PSET,ly->col.gray,hil,sha);
  238.         EV_SETFR(ev,evPos++, 0, dlg,BlkDlgMoveEvFunc,win,EVSW_LEFT,
  239.           xx1, yy1, xx2, yy2);
  240.         if ( fs->title )
  241.         {
  242.             SCN_PUTS(SiFts->ftsSs2,fs->title,xx1+3,yy1+3,OPAQUE,ly->col.white,ly->col.gray);
  243.             SCN_PUTS(SiFts->ftsSs2,fs->title,xx1+2,yy1+2,PSET  ,ly->col.black,ly->col.gray);
  244.         }
  245.     }
  246.  
  247.     /* âëâCâgâ{â^âôâüâjâàü[    --------------------------------------------*/
  248.     {
  249.         CONST int    xx1 = x2-15, yy1 = y1;
  250.         CONST int    xx2 = x2,    yy2 = y1+15;
  251.  
  252.         SCN_PUTIMGPTN( &Ptn16x16_menu, xx1, yy1, OPAQUE, ly->col.black, ly->col.gray);
  253.         SCN_BOXCON(xx1,yy1,xx2,yy2,1,PSET,hil,sha);
  254.         EV_SETBTN1(ev,evPos++,0,fs,fsEvFunc_rightMenu,win,
  255.             EVSW_LEFT,xx1,yy1,xx2,yy2,1,hil,sha);
  256.     }
  257.  
  258.     /* âhâëâCâuâZâîâNâ^    ------------------------------------------------*/
  259.     fs->frDrv.x1 = x1      + 2;
  260.     fs->frDrv.y1 = y1 + 16 + 2;
  261.     fs->frDrv.x2 = x2      - 2;
  262.     fs->frDrv.y2 = y1 + 16 + 2 + 2+14+2+14+2 -1;
  263.     FileSel_dspDrv( fs );
  264.  
  265.     /* âtâ@âCâïû╝ò\Īÿg    ------------------------------------------------*/
  266.     fs->frFl.x1 = x1 + 2;
  267.     fs->frFl.y1 = fs->frDrv.y2+1+1;
  268.     fs->frFl.x2 = x2 - 2 -16 - 2;
  269.     fs->frFl.y2 = y2 - (2+12+2);
  270.     SCN_BOXF(fs->frFl.x1,fs->frFl.y1,fs->frFl.x2,fs->frFl.y2,PSET,ly->col.black);
  271.     if ( fs->err != FSERR_NOERR )
  272.     {
  273.         if ( fs->err == FSERR_UNREAD )
  274.             FileSel_changedir( fs );
  275.     }
  276.     if ( fs->err == FSERR_NOERR )
  277.     {    /* ò\Īé╖éΘ    */
  278.         FileSel_dspFndat( fs, -1 );
  279.     } else
  280.         FileSel_dspErr(fs);
  281.  
  282.     /* âXâNâìü[âïâoü[    ------------------------------------------------*/
  283.     {
  284.         SB_T    *sb = fs->sb;
  285.         FRAME_T    fr;
  286.  
  287.         fr.x1 = fs->frFl.x2 + 1 + 3;
  288.         fr.y1 = fs->frFl.y1;
  289.         fr.x2 = x2+1 - 3;
  290.         fr.y2 = y2-2-16-2;
  291.         SB_vDsp( sb, &fr );
  292.     }
  293.  
  294.     /* ôⁿù═âtâ@âCâïû╝    ------------------------------------------------*/
  295.     FileSel_dspFnbuf( fs );
  296.  
  297.     /* [âèâ^ü[âô]âLü[â{â^âô    --------------------------------------------*/
  298.     {
  299.         CONST int    xx1 = x2+1-16-2 -1, yy1 = y2+1-2-16 - 1;
  300.         CONST int    xx2 = xx1 + 15  +2, yy2 = yy1 + 15  + 2;
  301.  
  302.         SCN_BOXFCON(xx1,yy1,xx2,yy2,1,PSET, ly->col.gray, hil, sha);
  303.         SCN_PUTIMGPTN( &Ptn16x16_return, xx1+1, yy1+1, OPAQUE, ly->col.white,